package chain_of_responsibility_pattern.v1;

/**
 * 管理者类
 * @author ricejson
 */
public class Manager {
    private String name;

    public Manager(String name) {
        this.name = name;
    }

    public void handleRequest(String managerLevel, Request request) {
        if (managerLevel.equalsIgnoreCase("经理")) {
            // 处理经理相关的请求
            if (request.getRequestType().equals("请假") && request.getRequestNum() <= 2) {
                // 请假并且天数<=2
                System.out.println(name + ":" + request.getRequestContent() + " 数量" + request.getRequestNum() + "被批准");
            } else {
                // 其他事情无权处理
                System.out.println(name + ":" + request.getRequestContent() + " 数量" + request.getRequestNum() + "我无权处理");
            }
        } else if (managerLevel.equalsIgnoreCase("总监")) {
            // 处理总监相关的请求
            if (request.getRequestType().equals("请假") && request.getRequestNum() <= 5) {
                // 请假并且天数<=2
                System.out.println(name + ":" + request.getRequestContent() + " 数量" + request.getRequestNum() + "被批准");
            } else {
                // 其他事情无权处理
                System.out.println(name + ":" + request.getRequestContent() + " 数量" + request.getRequestNum() + "我无权处理");
            }
        } else if (managerLevel.equalsIgnoreCase("总经理")) {
            // 处理总经理相关的请求
            if (request.getRequestType().equals("请假")) {
                // 请假
                System.out.println(name + ":" + request.getRequestContent() + " 数量" + request.getRequestNum() + "被批准");
            } else if (request.getRequestType().equals("加薪") && request.getRequestNum() <= 500) {
                // 加薪<=500
                System.out.println(name + ":" + request.getRequestContent() + " 数量" + request.getRequestNum() + "我无权处理");
            } else if (request.getRequestType().equals("加薪") && request.getRequestNum() > 500) {
                // 加薪<=500
                System.out.println(name + ":" + request.getRequestContent() + " 数量" + request.getRequestNum() + "再说吧");
            }
        }
    }
}
